package com.sz.designpattern.create5.absfactory;

import com.sz.designpattern.create5.absfactory.iiterface.IProduct;
import com.sz.designpattern.create5.absfactory.iiterface.IProductFactory2;

public class SuperFactory implements IProductFactory2 {
    @Override
    public <T extends IProduct> T getProduct(Class<? extends IProduct> clz) {
        IProduct product = null;
        try {
            product = (IProduct) Class.forName(clz.getName()).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return (T) product;
    }
}
